/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.qihoo.gamecenter.sdk.login.plugin.profile;

import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Handler;
import android.provider.MediaStore.Images.Media;
import com.qihoo.gamecenter.sdk.common.i.h;
import com.qihoo.gamecenter.sdk.common.i.q;
import com.qihoo.gamecenter.sdk.common.i.s;
import com.qihoo.gamecenter.sdk.login.plugin.d;
import com.qihoo.gamecenter.sdk.login.plugin.d.a;
import com.qihoo.gamecenter.sdk.login.plugin.h.e;
import com.qihoo.gamecenter.sdk.login.plugin.h.g;
import com.qihoo.gamecenter.sdk.login.plugin.h.l;
import java.io.File;
import java.io.FileOutputStream;
import java.util.HashMap;

public class a {
    public static String a(Context paramContext, String paramString1, String paramString2, String paramString3) {
        e.a("ProfileUtils", "account = " + paramString1);
        HashMap localHashMap = new HashMap();
        localHashMap.put("account", paramString1);
        localHashMap.put("head_type", paramString2);
        localHashMap.put("fields", "nickname,head_pic");
        localHashMap.put("sec_fields", "secmobile");
        localHashMap.put("method", "CommonAccount.getAccountInfo");
        e.a("ProfileUtils", new Object[] { "getAccountInfoUrl params = " + localHashMap });
        String str = com.qihoo.gamecenter.sdk.common.e.a.a(localHashMap, s.q(paramContext));
        e.a("ProfileUtils", new Object[] { "getAccountInfoUrl url = " + str });
        return str;
    }

    public static String a(Context paramContext, String paramString1, String paramString2) {
        HashMap localHashMap = new HashMap();
        localHashMap.put("head_type", paramString1);
        localHashMap.put("method", "UserIntf.modifyUserHeadShot");
        e.a("ProfileUtils", new Object[] { "getModifyUserHeadShotUrl params = " + localHashMap });
        String str = com.qihoo.gamecenter.sdk.common.e.a.a(localHashMap, s.q(paramContext));
        e.a("ProfileUtils", new Object[] { "getModifyUserHeadShotUrl url = " + str });
        return str;
    }

    public static void a(Activity paramActivity, File paramFile) {
        try {
            Intent localIntent = new Intent("android.media.action.IMAGE_CAPTURE");
            File localFile = paramFile.getParentFile();
            if (!(localFile.exists()))
                localFile.mkdirs();
            localIntent.putExtra("output", Uri.fromFile(paramFile));
            paramActivity.startActivityForResult(localIntent, 2);
        } catch (Exception localException) {
            e.b("ProfileUtils", "takePhoto exception is " + localException.getLocalizedMessage());
        }
    }

    public static void a(Activity paramActivity) {
        try {
            Intent localIntent = new Intent("android.intent.action.PICK", null);
            localIntent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*");
            paramActivity.startActivityForResult(localIntent, 1);
        } catch (ActivityNotFoundException localActivityNotFoundException) {
            q.a(paramActivity, d.a(d.a.db), 0, 80);
        } catch (Exception localException) {
            e.b("ProfileUtils", "selectPic exception is " + localException.getLocalizedMessage());
        }
    }

    public static void a(Context paramContext, String paramString, Handler paramHandler) {
        l.a(paramContext, paramString, paramHandler);
    }

    public static void a(Context paramContext, String paramString, boolean paramBoolean) {
        StringBuilder localStringBuilder = new StringBuilder();
        localStringBuilder.append("gamecenter_sdk_plugin_key_refuse_modify_headshot");
        localStringBuilder.append(paramString);
        g.a(paramContext, localStringBuilder.toString(), paramBoolean);
    }

    public static boolean a(Context paramContext, String paramString) {
        StringBuilder localStringBuilder = new StringBuilder();
        localStringBuilder.append("gamecenter_sdk_plugin_key_refuse_modify_headshot");
        localStringBuilder.append(paramString);
        return g.f(paramContext, localStringBuilder.toString());
    }

    public static boolean b(Context paramContext, String paramString) {
        StringBuilder localStringBuilder = new StringBuilder();
        localStringBuilder.append("gamecenter_sdk_plugin_key_headshot");
        localStringBuilder.append(paramString);
        return g.f(paramContext, localStringBuilder.toString());
    }

    public static void b(Context paramContext, String paramString, boolean paramBoolean) {
        StringBuilder localStringBuilder = new StringBuilder();
        localStringBuilder.append("gamecenter_sdk_plugin_key_headshot");
        localStringBuilder.append(paramString);
        g.a(paramContext, localStringBuilder.toString(), paramBoolean);
    }

    public static File a(Context paramContext, int paramInt) {
        File localFile1 = new File(paramContext.getCacheDir(), "head_pic");
        if (!(localFile1.exists()))
            localFile1.mkdirs();
        File localFile2 = new File(localFile1, "upload_temp");
        localFile2.deleteOnExit();
        FileOutputStream localFileOutputStream = null;
        try {
            localFileOutputStream = new FileOutputStream(localFile2);
            byte[] arrayOfByte = com.qihoo.gamecenter.sdk.login.plugin.f.a.a(paramContext).b(paramInt);
            if (arrayOfByte != null) {
                localFileOutputStream.write(arrayOfByte);
                localFileOutputStream.flush();
            }
        } catch (Throwable localThrowable) {
            e.b("ProfileUtils", "genTempFileFromResource error", localThrowable);
        } finally {
            if (localFileOutputStream != null) {
                h.a(localFileOutputStream);
                localFileOutputStream = null;
            }
        }
        return localFile2;
    }
}